package com.genexususa.eo.bing.data.wsSubclasses;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.HourTarget;
import com.genexususa.eo.bing.CampaignManagementServiceClasses.HourTargetBid;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class GxHourTarget extends HourTarget {
    public GxHourTarget(Element element) {
        NodeList bidsNode = element.getElementsByTagName("HourTargetBidCollection");
        if (bidsNode.getLength() > 0) {
            NodeList hourTargetBidNode = ((Element)bidsNode.item(0)).getElementsByTagName("HourTargetBid");
            HourTargetBid[] hourTargetBids = new HourTargetBid[hourTargetBidNode.getLength()];
            for (int temp = 0; temp < hourTargetBidNode.getLength(); temp++) {
                hourTargetBids[temp] = new GxHourTargetBid((Element)hourTargetBidNode.item(temp));
            }
            this.setBids(hourTargetBids);
        }
        if (element.getElementsByTagName("TargetAllHours").getLength() > 0 &&
            element.getElementsByTagName("TargetAllHours").item(0).getChildNodes().getLength() > 0) {
            this.setTargetAllHours(Boolean.valueOf(element.getElementsByTagName("TargetAllHours").item(0).getChildNodes().item(0).getNodeValue()));
        }
    }
}
